< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03120306.xhp

(section: mid) (bookmark: bm_id3143268)
Mid function
Mid statement

Mid 関数
Mid ステートメント

Mid Function, Mid Statement [Runtime]
Mid 関数、Mid ステートメント [実行時](hd_id3143268.1)

Returns the specified portion of a string expression (Mid function), or replaces the portion of a string expression with another string (Mid statement).
文字列表式の中から指定部分を取得して返す (Mid 関数) か、該当部分を他の文字列に置き換えます (Mid ステートメント)。(par_id3148473.2)

(/section: mid)

Syntax:
構文:(hd_id3154285.3)

Mid (Text As String, Start As Long [, Length As Long]) or Mid (Text As String, Start As Long , Length As Long, Text As String)
Mid (Text As String, Start As Integer [, Length As Integer]) または Mid (Text As String, Start As Integer , Length As Integer, Text As String)(par_id3147530.4)

Return value:
戻り値:(hd_id3145068.5)

String (only by Function)
文字列 (関数のみ)(par_id3149295.6)

Parameters:
パラメータ:(hd_id3154347.7)

Text: Any string expression that you want to modify.
Text: 操作対象とする文字列表式。(par_id3148664.8)

Start: Numeric expression that indicates the character position within the string where the string portion that you want to replace or to return begins. The maximum allowed value is 65535.
Start: 指定文字列中での、取得ないし置換の開始文字位置を示す整数表式。使用できる最大値は 65535 です。(par_id3150359.9)

Length: Numeric expression that returns the number of characters that you want to replace or return. The maximum allowed value is 65535.
Length: 取得ないし置換する文字の長さを示す整数表式。(par_id3148451.10)

If the Length parameter in the Mid function is omitted, all characters in the string expression from the start position to the end of the string are returned.
Mid 関数 の場合、Length パラメータを指定しないと、指定文字列の開始位置から末尾までが返されます。(par_id3125864.11)

If the Length parameter in the Mid statement is less than the length of the text that you want to replace, the text is reduced to the specified length.
Mid ステートメント の場合、Length パラメータの値が置き換えるテキストよりも短いと、この長さにテキストが切りつめられます。(par_id3144762.12)

Text: The string to replace the string expression (Mid statement).
Text: 文字列表式を置き換える文字列 (Mid ステートメント)。(par_id3150769.13)

(embed text/sbasic/shared/00000003.xhp#errorcode : linkinfo)

Error Codes

エラーコード(hd_id3152869.37)

(/embed text/sbasic/shared/00000003.xhp#errorcode)

(embed text/sbasic/shared/00000003.xhp#err5 : linkinfo)

5 Invalid procedure call
5 無効なプロシージャー呼び出しです (par_id3150891.41)

(/embed text/sbasic/shared/00000003.xhp#err5)

Example:
例:(hd_id3149560.14)

Sub ExampleUSDate
Sub ExampleUSDate(par_id3150439.15)

Dim sInput As String
Dim sInput As String(par_id3147349.16)

Dim sUS_date As String
Dim sUS_date As String(par_id3155854.17)

sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'")
sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'")(par_id3153189.18)

sUS_date = Mid(sInput, 6, 2)
sUS_date = Mid(sInput, 6, 2)(par_id3148645.19)

sUS_date = sUS_date & "/"
sUS_date = sUS_date & "/"(par_id3153952.20)

sUS_date = sUS_date & Right(sInput, 2)
sUS_date = sUS_date & Right(sInput, 2)(par_id3153364.21)

sUS_date = sUS_date & "/"
sUS_date = sUS_date & "/"(par_id3146975.22)

sUS_date = sUS_date & Left(sInput, 4)
sUS_date = sUS_date & Left(sInput, 4)(par_id3149665.23)

MsgBox sUS_date
MsgBox sUS_date(par_id3150011.24)

End Sub
End Sub(par_id3148618.25)


< Prev / Next >